package com.bangbang.blog.controller;


import com.bangbang.blog.pojo.TbLabel;
import com.bangbang.blog.service.impl.TbLabelServiceImpl;
import com.bangbang.configresult.Result;
import com.bangbang.configresult.ResultEnum;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 标签表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-11
 */
@RestController
@RequestMapping("/blog/tbLabel")
public class TbLabelController {

    @Autowired
    private TbLabelServiceImpl tbLabelService;


    //新增
    @PostMapping
    @ApiOperation("标签添加方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbLabel",value = "标签实体类",required = true,paramType = "body")
    })
    public Result insert(@RequestBody TbLabel tbLabel){
        tbLabelService.insert(tbLabel);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //修改
    @PutMapping
    @ApiOperation("标签修改方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbLabel",value = "标签实体类",required = true,paramType = "body")
    })
    public Result update(@RequestBody TbLabel tbLabel){
        tbLabelService.updateById(tbLabel);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //删除
    @DeleteMapping
    @ApiOperation("标签删除方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "labId",value = "标签id",required = true,paramType = "query")
    })
    public Result delete(@RequestParam(required = true)Long labId){
        tbLabelService.delete(labId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //查询
    @GetMapping
    @ApiOperation("标签查询方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "labId",value = "标签实体类",required = true,paramType = "query")
    })
    public Result select(@RequestParam(required = true)Long labId){
        tbLabelService.select(labId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

}

